package com.cykj.web.controller.posbiz;

import java.util.List;
import java.util.Arrays;

import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cykj.common.annotation.Log;
import com.cykj.common.core.controller.BaseController;
import com.cykj.common.core.domain.AjaxResult;
import com.cykj.common.enums.BusinessType;
import com.cykj.pos.domain.BizTransactionAmount;
import com.cykj.pos.service.IBizTransactionAmountService;
import com.cykj.common.utils.poi.ExcelUtil;
import com.cykj.common.core.page.TableDataInfo;

/**
 * pos1.0交易通知(今日)Controller
 *
 * @author tzf
 * @date 2025-06-17
 */
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/pos/todayTrans" )
public class BizTransactionAmountController extends BaseController {

    private final IBizTransactionAmountService iBizTransactionAmountService;

    /**
     * 查询pos1.0交易通知(今日)列表
     */
    @PreAuthorize("@ss.hasPermi('pos:todayTrans:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizTransactionAmount bizTransactionAmount) {
        startPage();
        List<BizTransactionAmount> list = iBizTransactionAmountService.queryList(bizTransactionAmount);
        return getDataTable(list);
    }

    /**
     * 导出pos1.0交易通知(今日)列表
     */
    @PreAuthorize("@ss.hasPermi('pos:todayTrans:export')" )
    @Log(title = "pos1.0交易通知(今日)" , businessType = BusinessType.EXPORT)
    @GetMapping("/export" )
    public AjaxResult export(BizTransactionAmount bizTransactionAmount) {
        List<BizTransactionAmount> list = iBizTransactionAmountService.queryList(bizTransactionAmount);
        ExcelUtil<BizTransactionAmount> util = new ExcelUtil<BizTransactionAmount>(BizTransactionAmount.class);
        return util.exportExcel(list, "todayTrans" );
    }

    /**
     * 获取pos1.0交易通知(今日)详细信息
     */
    @PreAuthorize("@ss.hasPermi('pos:todayTrans:query')" )
    @GetMapping(value = "/{id}" )
    public AjaxResult getInfo(@PathVariable("id" ) Long id) {
        return AjaxResult.success(iBizTransactionAmountService.getById(id));
    }

    /**
     * 新增pos1.0交易通知(今日)
     */
    @PreAuthorize("@ss.hasPermi('pos:todayTrans:add')" )
    @Log(title = "pos1.0交易通知(今日)" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizTransactionAmount bizTransactionAmount) {
        return toAjax(iBizTransactionAmountService.save(bizTransactionAmount) ? 1 : 0);
    }

    /**
     * 修改pos1.0交易通知(今日)
     */
    @PreAuthorize("@ss.hasPermi('pos:todayTrans:edit')" )
    @Log(title = "pos1.0交易通知(今日)" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizTransactionAmount bizTransactionAmount) {
        return toAjax(iBizTransactionAmountService.updateById(bizTransactionAmount) ? 1 : 0);
    }

    /**
     * 删除pos1.0交易通知(今日)
     */
    @PreAuthorize("@ss.hasPermi('pos:todayTrans:remove')" )
    @Log(title = "pos1.0交易通知(今日)" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}" )
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(iBizTransactionAmountService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
    }

    // 统计
    @PostMapping("/executeStatistics")
    public AjaxResult executeStatistics (@RequestBody BizTransactionAmount bizTransactionAmount){
        return iBizTransactionAmountService.executeStatistics(bizTransactionAmount);
    }
}
